package com.yunsom.testdemo.design.composite;

/**
 * @author Xbao
 * @description 组合模式
 * @date 2022/6/22 13:58
 */
public class TestComposite {

  public static void main(String[] args) {

    Employee ceo = new Employee("Jobs", "CEO", 50*1000);

    Employee advancedSaler = new Employee("Mr.Zhao", "Head of Salers", 30*1000);
    Employee advancedDeveloper = new Employee("Mr.Zhang", "Head of Developer", 30*1000);

    Employee developer1 = new Employee("Lin", "Developer", 25*1000);
    Employee developer2 = new Employee("Chen", "Developer", 20*1000);

    Employee saler1 = new Employee("Wang", "Saler", 30*1000);
    Employee saler2 = new Employee("Li", "Saler", 30*1000);

    ceo.add(advancedDeveloper);
    ceo.add(advancedSaler);

    advancedDeveloper.add(developer1);
    advancedDeveloper.add(developer2);

    advancedSaler.add(saler1);
    advancedSaler.add(saler2);

    // 输出所有员工
    System.out.println(ceo);
    for (Employee advancedEmployee : ceo.getSubordinates()) {
      System.out.println(advancedEmployee);
      for (Employee ordinaryEmployee : advancedEmployee.getSubordinates()) {
        System.out.println(ordinaryEmployee);
      }
    }

  }
}
